home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5067 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. Path: news.uni-jena.de!news
  2. From: mkt@isun04.inf.uni-jena.de (Tilo Koerbs)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: template problem in BC++ 3.0
  5. Date: 2 Feb 1996 11:40:39 GMT
  6. Organization: Lehrstuhl fuer Rechnerarchitektur- und kommunikation, FSU Jena
  7. Message-ID: <4est7n$80l@fsuj01.rz.uni-jena.de>
  8. References: <96032.164531F0O@psuvm.psu.edu>
  9. Reply-To: mkt@isun04.inf.uni-jena.de
  10. NNTP-Posting-Host: isun07.inf.uni-jena.de
  11.  
  12. This problem is well known: *** templates and separate compilation ***
  13.  
  14. The compiler when comiling the template function does not know
  15. anything about the function calls. So it cannot generate code
  16. for the function (not even something like a typeless code) because
  17. it don't knows the types for which to compile the function.
  18.  
  19. When comiling the application of the function the compiler does
  20. not know anything of the template function implementation.
  21. So the compiler is unable to generate code for the template function.
  22. But of course it can generate a function call!
  23.  
  24. The comes the linker. It finds the function call and searches for
  25. the function implementation. But there is no!
  26. Only solution: the linker knows of templates. Then it needs a way
  27. to find out something about the template function implementation.
  28. This is usualy done by a 'template database' generated by the
  29. compiler whenever it meets a template in the source code.
  30. From this database the linker gets the information which source
  31. code file contains the template function implementation.
  32. And now? The linker calls the compiler by telling which type
  33. to use for the template. then the compiler compiles the code
  34. and returns it to the linker.
  35.  
  36. You Borland C++ does not know of this technique!
  37.  
  38. But as you stated, if you put all the things together in one
  39. translation unit, the compiler has access to all the things it
  40. needs to compile the template code.
  41.  
  42. Bye.
  43. Tilo Koerbs
  44.  
  45.  
  46.  
  47.